﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace ApiServer.Controllers
{
    
    [ApiController]
    [Route("[controller]")]
    public class AccountController : ControllerBase
    {
        private readonly ILogger<AccountController> _logger;

        public AccountController(ILogger<AccountController> logger)
        {
            _logger = logger;
        }

        //自定义授权策略
        [Authorize(Policy = "eMailPolicy")]
        [HttpGet("Get")]
        public IActionResult Get()
        {

            foreach (var c in User.Claims)
            {
                ObjectDumper.Write(c);
            }
            var obj = from c in User.Claims select new { c.Type, c.Value };
            return new JsonResult(obj);
        }

       
    }
}
